package demo.android.myapplication

import android.util.Log
import okhttp3.*
import java.io.IOException
import java.net.InetAddress

/**
 * <br>createBy Gw
 * <br>createTime: 2021/6/25 14:59
 */

fun test(){
    var client:OkHttpClient = OkHttpClient()
    var request:Request = Request.Builder()
        .url("https://www.baidu.com")
        .get()
        .build()

    client.newCall(request).enqueue(object : Callback {

        override fun onResponse(call: Call, response: Response) {
            Log.i("OK-HTTP", "onResponse ${Thread.currentThread()}")
        }

        override fun onFailure(call: Call, e: IOException) {
            Log.i("OK-HTTP", "onFailure ${Thread.currentThread()}")
        }

    })
}

fun main(){
    val names = InetAddress.getAllByName("www.baidu.com")
    names.forEach {
        println(it.hostAddress)
    }
}